package com.wn.common.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Rsp {

    private Integer code;//状态码
    private String msg;//信息
    private Object content;//数据


    public static Rsp success(Object object){
        Rsp rsp = new Rsp();

        rsp.setCode(20000);
        rsp.setMsg("请求成功");
        rsp.setContent(object);

        return rsp;
    }


    public static Rsp fail(){
        Rsp rsp = new Rsp();

        rsp.setCode(50000);
        rsp.setMsg("请求失败！");
        rsp.setContent(null);

        return rsp;
    }

    public Rsp code(Integer code){

        this.setCode(code);

        return this;
    }

    public Rsp msg(String msg){

        this.setMsg(msg);

        return this;
    }

}
